package com.myproject.mall.common.util;

import com.huaban.analysis.jieba.JiebaSegmenter;

import java.util.Iterator;
import java.util.List;

public class WordUtil {
    private static  WordUtil wordUtil;
    private static final JiebaSegmenter js = new JiebaSegmenter();

    private WordUtil(){}

    public static synchronized WordUtil getInstance(){
        if(wordUtil == null){
            wordUtil = new WordUtil();
        }
        return wordUtil;
    }

    public List<String> word(String sentence)
    {
        List<String> list = js.sentenceProcess(sentence);
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            String word = iterator.next();
            if(word.matches("[我你他她它的得啊呀也就，‘“”’。？.!、/ ]")){
                iterator.remove();
            }
        }
        return list;
    }
}
